﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace QuickFramework.SqlSugarOrm
{
    public partial interface IRepository<T> // where T : Shared.Contracts.EntityBase,new()
    {
        #region Deleteable
        IDeleteable<T> Deleteable(IUnitOfWork unitOfWork = null);
        IDeleteable<T> Deleteable(dynamic primaryKeyValue, IUnitOfWork unitOfWork = null);
        IDeleteable<T> Deleteable(dynamic[] primaryKeyValues, IUnitOfWork unitOfWork = null);
        IDeleteable<T> Deleteable(Expression<Func<T, bool>> expression, IUnitOfWork unitOfWork = null);
        IDeleteable<T> Deleteable(List<dynamic> pkValue, IUnitOfWork unitOfWork = null);
        IDeleteable<T> Deleteable(List<T> deleteObjs, IUnitOfWork unitOfWork = null);
        IDeleteable<T> Deleteable(T deleteObj, IUnitOfWork unitOfWork = null);
        #endregion

        #region Insertable
        IInsertable<T> Insertable(Dictionary<string, object> columnDictionary, IUnitOfWork unitOfWork = null);
        IInsertable<T> Insertable(dynamic insertDynamicObject, IUnitOfWork unitOfWork = null);
        IInsertable<T> Insertable(List<T> insertObjs, IUnitOfWork unitOfWork = null);
        IInsertable<T> Insertable(T insertObj, IUnitOfWork unitOfWork = null);
        IInsertable<T> Insertable(T[] insertObjs, IUnitOfWork unitOfWork = null);
        #endregion

        #region Queryable
        ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T> Queryable(IUnitOfWork unitOfWork = null);
        ISugarQueryable<T> Queryable(ISugarQueryable<T> queryable, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T> Queryable(string shortName, IUnitOfWork unitOfWork = null);
        #endregion

        #region Saveable
        ISaveable<T> Saveable(List<T> saveObjects, IUnitOfWork unitOfWork = null);
        ISaveable<T> Saveable(T saveObject, IUnitOfWork unitOfWork = null);
        #endregion

        #region Queue
        QueueList Queues(IUnitOfWork unitOfWork = null);
        void AddQueue(string sql, object parsmeters = null, IUnitOfWork unitOfWork = null);
        void AddQueue(string sql, List<SugarParameter> parsmeters, IUnitOfWork unitOfWork = null);
        void AddQueue(string sql, SugarParameter parsmeter, IUnitOfWork unitOfWork = null);

        int SaveQueues(IUnitOfWork unitOfWork = null);
        Task<int> SaveQueuesAsync(IUnitOfWork unitOfWork = null);
        #endregion


        #region Queryable
        ISugarQueryable<T1> SqlQueryable<T1>(string sql, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1: class, new();
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8> Queryable<T1, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8> Queryable<T1, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7, T8> Queryable<T1, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7> Queryable<T1, T2, T3, T4, T5, T6, T7>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7> Queryable<T1, T2, T3, T4, T5, T6, T7>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6, T7> Queryable<T1, T2, T3, T4, T5, T6, T7>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6> Queryable<T1, T2, T3, T4, T5, T6>(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3, T4, T5, T6> Queryable<T1, T2, T3, T4, T5, T6>(Expression<Func<T1, T2, T3, T4, T5, T6, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5, T6> Queryable<T1, T2, T3, T4, T5, T6>(Expression<Func<T1, T2, T3, T4, T5, T6, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5> Queryable<T1, T2, T3, T4, T5>(Expression<Func<T1, T2, T3, T4, T5, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3, T4, T5> Queryable<T1, T2, T3, T4, T5>(Expression<Func<T1, T2, T3, T4, T5, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4, T5> Queryable<T1, T2, T3, T4, T5>(Expression<Func<T1, T2, T3, T4, T5, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4> Queryable<T1, T2, T3, T4>(Expression<Func<T1, T2, T3, T4, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3, T4> Queryable<T1, T2, T3, T4>(Expression<Func<T1, T2, T3, T4, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3, T4> Queryable<T1, T2, T3, T4>(Expression<Func<T1, T2, T3, T4, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3> Queryable<T1, T2, T3>(Expression<Func<T1, T2, T3, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2, T3> Queryable<T1, T2, T3>(Expression<Func<T1, T2, T3, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2, T3> Queryable<T1, T2, T3>(Expression<Func<T1, T2, T3, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2> Queryable<T1, T2>(Expression<Func<T1, T2, bool>> joinExpression, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1, T2> Queryable<T1, T2>(Expression<Func<T1, T2, JoinQueryInfos>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2> Queryable<T1, T2>(Expression<Func<T1, T2, object[]>> joinExpression, IUnitOfWork unitOfWork = null);
        ISugarQueryable<T1, T2> Queryable<T1, T2>(ISugarQueryable<T1> joinQueryable1, ISugarQueryable<T2> joinQueryable2, Expression<Func<T1, T2, bool>> joinExpression, IUnitOfWork unitOfWork = null)
            where T1 : class, new()
            where T2 : class, new();
        ISugarQueryable<T1, T2> Queryable<T1, T2>(ISugarQueryable<T1> joinQueryable1, ISugarQueryable<T2> joinQueryable2, JoinType joinType, Expression<Func<T1, T2, bool>> joinExpression, IUnitOfWork unitOfWork = null)
            where T1 : class, new()
            where T2 : class, new();
        ISugarQueryable<T1> Queryable<T1>(IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1> Queryable<T1>(ISugarQueryable<T1> queryable, IUnitOfWork unitOfWork = null) where T1 : class, new();
        ISugarQueryable<T1> Queryable<T1>(string shortName, IUnitOfWork unitOfWork = null) where T1 : class, new();
        #endregion


        #region Updateable
        IUpdateable<T> Updateable(IUnitOfWork unitOfWork = null);
        IUpdateable<T> Updateable(Dictionary<string, object> columnDictionary, IUnitOfWork unitOfWork = null);
        IUpdateable<T> Updateable(dynamic updateDynamicObject, IUnitOfWork unitOfWork = null);
        IUpdateable<T> Updateable(Expression<Func<T, bool>> columns, IUnitOfWork unitOfWork = null);
        IUpdateable<T> Updateable(Expression<Func<T, T>> columns, IUnitOfWork unitOfWork = null);
        IUpdateable<T> Updateable(List<T> UpdateObjs, IUnitOfWork unitOfWork = null);
        IUpdateable<T> Updateable(T UpdateObj, IUnitOfWork unitOfWork = null);
        IUpdateable<T> Updateable(T[] UpdateObjs, IUnitOfWork unitOfWork = null);
        #endregion
    }
}
